package com.cskaoyan.thread02.model.edition1;

/*
      该类表示盛放包子的蒸笼
 */
public class Container {
    // 定义成员变量，表示蒸笼中的包子
    private Food food;


    /*
          表示从蒸笼中取出包子吃(消费者调用)
     */
    public void eatFood() {
        System.out.println(Thread.currentThread().getName() + "吃包子：" + food);
        // 包子被吃掉了
        food = null;
    }


    /*
         表示将包子放入蒸笼
     */
    public void setFood(Food newFood) {
        System.out.println(Thread.currentThread().getName() + "做包子: " + newFood);
        food = newFood;
    }


    /*
        该方法用来判断蒸笼是否为空
     */
    public boolean isEmpty () {
        return food == null;
    }

}

/*
      该类表示蒸笼中的包子
 */
class Food {
    private String name;

    private double price;

    public Food(String name, double price) {
        this.name = name;
        this.price = price;
    }

    @Override
    public String toString() {
        return "Food{" +
                "name='" + name + '\'' +
                ", price=" + price +
                '}';
    }
}
